﻿using Pay.AliPay;
using Pay.WxPay;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class PayContext
{
    public static string PayParams(string tradeNo, string subject, string body, string totalfee, PayType payType = PayType.WechatPay, string openid = "")
    {
        switch (payType)
        {
            case PayType.AliPay: return AliPayContext.Instance.PreOrder(tradeNo, subject, body, totalfee);
            case PayType.WechatPay: return WxPayContext.H5Instance.PreOrder(tradeNo, subject, body, totalfee, "JSAPI", openid);
            case PayType.WechatAppPay: return WxPayContext.Instance.PreOrder(tradeNo, subject, body, totalfee, "APP");
            default: return null;
        }
    }
}

/// <summary>
/// 支付类型
/// </summary>
public enum PayType : int
{
    /// <summary>
    /// 未支付
    /// </summary>
    [Description("未支付")]
    NoPay = 0,
    /// <summary>
    /// 微信支付
    /// </summary>
    [Description("微信公众号支付")]
    WechatPay = 1,
    /// <summary>
    /// 支付宝支付
    /// </summary>
    [Description("支付宝支付")]
    AliPay = 2,
    /// <summary>
    /// 苹果支付
    /// </summary>
    [Description("苹果支付")]
    ApplePay = 3,
    /// <summary>
    /// 钱包支付
    /// </summary>
    [Description("钱包支付")]
    WalletPay = 4,
    /// <summary>
    /// 微信支付
    /// </summary>
    [Description("微信APP支付")]
    WechatAppPay = 5,
    /// <summary>
    /// 可用体验金支付
    /// </summary>
    [Description("可用体验金支付")]
    CanUsedPointPay = 6,
    /// <summary>
    /// 体验金支付
    /// </summary>
    [Description("体验金支付")]
    PointPay = 7,
}

/// <summary>
/// 退款状态
/// </summary>
public enum RefunStatus : int
{
    /// <summary>
    /// 初始化
    /// </summary>
    Init = 0,
    /// <summary>
    /// 成功
    /// </summary>
    SUCCESS = 1,
    /// <summary>
    /// 关闭
    /// </summary>
    REFUNDCLOSE = 2,
    /// <summary>
    /// 处理中
    /// </summary>
    PROCESSING = 3,
    /// <summary>
    /// 退款异常，退款到银行发现用户的卡作废或者冻结了，导致原路退款银行卡失败，可前往商户平台（pay.weixin.qq.com）-交易中心，手动处理此笔退款
    /// </summary>
    CHANGE = 4
}
